package com.fingard.dsp.bank.directbank.abc02;


import com.fingard.dsp.bank.directbank.PaymentState;
import com.fingard.dsp.bank.directbank.bankInterface.ISinglePay;
import com.fingard.dsp.bank.reqrespobj.single.*;
import com.fingard.dsp.bank.reqrespobj.single.detail.RetAtsSglDetail;
import com.fingard.net.ConnState;
import com.fingard.text.StringHelper;
import com.fingard.xml.XElement;
import com.fingard.xml.XmlTextReader;
import com.fingard.xml.XmlTextWriter;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;

@Component("ABC02SinglePay")
public class ABC02SinglePay extends ABC02Base implements ISinglePay {

    //单笔支付，不需采用流处理方式
    @Override
    public RetAtsSingle d_1908_SglPay(ReqSingle p_req1908) throws Exception {
        //返回ATS的对象
        RetAtsSingle retAts = new RetAtsSingle(p_req1908.reqHeader);
        RetAtsSglDetail tmpRetDetail;
        if ("190801".equals(p_req1908.reqHeader.commandCode)) {
            tmpRetDetail = d_190801(p_req1908);
        } else if ("190802A".equals(p_req1908.reqHeader.commandCode)) {
            tmpRetDetail = d_190802A(p_req1908);
        } else {
            tmpRetDetail = d_190802(p_req1908);
        }
        if (tmpRetDetail.respCode.equals("-1") && StringHelper.isNullOrEmpty(tmpRetDetail.reqSeqID)) {
            tmpRetDetail.reqSeqID = p_req1908.singleDetail.askNumber;
        }
        retAts.writeRetDetail(tmpRetDetail);
        return retAts;
    }

    @Override
    public RetAtsSingleBat d_1908BAT_SglBatPay(ReqSingleBat p_req1908BAT) throws Exception {
        return null;
    }

    //190802对外支付
    private RetAtsSglDetail d_190802(ReqSingle p_req1908) throws Exception {
        RetAtsSglDetail retDetail = new RetAtsSglDetail();

        try {
            //赋值通用参数
            ABC02Header bankHeader = new ABC02Header();
            if (p_req1908.singleDetail.isPrivate.equals("1") && p_req1908.singleDetail.sameBnk.equals("1")) {
                //同行对私
                bankHeader.CCTransCode = "CFRT21";
            } else {
                bankHeader.CCTransCode = "CFRT02";
            }
            bankHeader.ReqSeqNo = p_req1908.singleDetail.askNumber;
            bankHeader.ReqDateTime = p_req1908.singleDetail.getPayDateTime();
            XmlTextWriter xmlWriter = new XmlTextWriter();//发银行报文的XML对象
            //写入通用的头部节点
            writeCommonHeader(xmlWriter, bankHeader);
            xmlWriter.writeElementString("Amt", p_req1908.singleDetail.payAmount);
            xmlWriter.writeStartElement("Cmp");
            String dbProv = p_req1908.singleDetail.payArea;
            if (getBankConfig().getValueAsBool("payActInfoSetOwnerArea")) {
                dbProv = getAbcAccProv(p_req1908.singleDetail.payAct,dbProv);
            }
            xmlWriter.writeElementString("DbProv", dbProv);
            xmlWriter.writeElementString("DbAccNo", getAbcAccNo(p_req1908.singleDetail.payAct));
            xmlWriter.writeElementString("DbLogAccNo",getAbcLogAccNo(p_req1908.singleDetail.payAct));
            xmlWriter.writeElementString("DbCur", this.convertCurToBank(p_req1908.singleDetail.payCur));
            if (p_req1908.singleDetail.sameBnk.equals("1")) {
                String crProv = p_req1908.singleDetail.recArea;
                if (getBankConfig().getValueAsBool("useActInfoSetOwnerArea")) {
                    crProv = getAbcAccProv(p_req1908.singleDetail.recAct,crProv);
                }
                xmlWriter.writeElementString("CrProv", crProv);
                xmlWriter.writeElementString("CrAccNo", getAbcAccNo(p_req1908.singleDetail.recAct));
            } else {
                xmlWriter.writeElementClosed("CrProv");
                xmlWriter.writeElementString("CrAccNo", p_req1908.singleDetail.recAct);
            }
            xmlWriter.writeElementString("CrLogAccNo",getAbcLogAccNo(p_req1908.singleDetail.recAct));
            xmlWriter.writeElementString("CrCur", this.convertCurToBank(p_req1908.singleDetail.recCur));
            xmlWriter.writeElementString("ConFlag", "1");
            xmlWriter.writeEndElement();
            //需要进行对账码拼接以及节点解析，采用XElement进行处理
            //单笔、批量共用节点赋值方法
            XElement tmpXElement = new XElement("Corp", "");
            tmpXElement.addChild(new XElement("PsFlag", ""));
            tmpXElement.addChild(new XElement("BookingFlag", "0"));
            tmpXElement.addChild(new XElement("BookingDate", ""));//p_req1908.singleDetail.payDate
            tmpXElement.addChild(new XElement("BookingTime", ""));//p_req1908.singleDetail.payTime
            String urgencyFlag = p_req1908.singleDetail.paySpd;//加急标识
            if (p_req1908.singleDetail.sameBnk.equals("1")) {
                tmpXElement.addChild(new XElement("OthBankFlag", "0"));
            } else {
                tmpXElement.addChild(new XElement("OthBankFlag", "1"));
                String urgentFlag = getBankConfig().getValueAsString("UrgentLargeAmount");
                if (StringHelper.hasAnyChar(urgentFlag)) {
                    if ((new BigDecimal(p_req1908.singleDetail.payAmount)).compareTo(new BigDecimal(urgentFlag)) >= 0) {
                        urgencyFlag = "1";
                    }
                }
            }
            tmpXElement.addChild(new XElement("UrgencyFlag", urgencyFlag));
            tmpXElement.addChild(new XElement("CrBankType", ""));
            tmpXElement.addChild(new XElement("CrAccName", p_req1908.singleDetail.recName));
            tmpXElement.addChild(new XElement("CrBankName", p_req1908.singleDetail.recBankLocation));
            tmpXElement.addChild(new XElement("CrBankNo", p_req1908.singleDetail.cnapsCode));
            tmpXElement.addChild(new XElement("DbAccName", p_req1908.singleDetail.payName));
            tmpXElement.addChild(new XElement("WhyUse", p_req1908.singleDetail.purpose));
            tmpXElement.addChild(new XElement("Postscript", p_req1908.singleDetail.abstractATS));

            nodeAnalysis(p_req1908.singleDetail.srcXElement, tmpXElement, getCharset());

            xmlWriter.writeXElement(tmpXElement);

            xmlWriter.writeEndDocument();//写入报文完成
            String[] tmpStrRet = sendToBank(xmlWriter.toXmlString());//发送银行
            if (tmpStrRet[0].length() == 0) {
                StringBuilder tmpSbMsg = new StringBuilder();
                //解析银行返回
                XmlTextReader tmpBkReader = loadBankRespXmlReader(tmpStrRet[1], tmpSbMsg);
                if (tmpBkReader != null) {
                    String tmpRespCode = tmpBkReader.getFirstText("/ap/RespCode");
                    String tmpRetInfo = tmpBkReader.getFirstText("/ap/RespInfo");
                    String tmpRetRxtInfo = tmpBkReader.getFirstText("/ap/RxtInfo");
                    String tmpRespSource = tmpBkReader.getFirstText("/ap/RespSource");

                    retDetail.respCode = "0";
                    retDetail.reqSeqID = p_req1908.singleDetail.askNumber;
                    retDetail.transState = tmpRespSource + "+" + tmpRespCode;
                    String tmpWaitFlag = tmpBkReader.getFirstText("/ap/Corp/WaitFlag");
                    if (tmpWaitFlag != null && tmpWaitFlag.length() > 0) {
                        retDetail.transState = retDetail.transState + "+" + tmpWaitFlag;
                    }
                    retDetail.payInfoCode = tmpRespCode;
                    retDetail.respInfo = StringHelper.joinNotEmpty("+", tmpRetInfo, tmpRetRxtInfo);
                } else {
                    retDetail.respCode = "-1";
                    retDetail.respInfo = tmpSbMsg.toString();
                }
            } else if (tmpStrRet[0].equals(ConnState.FAIL)) {
                retDetail.respCode = "0";
                retDetail.respInfo = tmpStrRet[1];
                retDetail.reqSeqID = p_req1908.singleDetail.askNumber;
                retDetail.transState = PaymentState.FAIL_Payment;
                retDetail.payInfoCode = tmpStrRet[0];
            } else {
                retDetail.respCode = "-1";
                retDetail.respInfo = tmpStrRet[1];
            }
        } catch (Exception ex) {
            ex.printStackTrace();

            retDetail.respCode = "-1";
            retDetail.respInfo = ex.getMessage();

            WriteBankLogLn(ex);
        }

        return retDetail;
    }

    /**
     * 参考文档：农行银企直连（银企通）接口文档20170103.wps
     * 参考章节：7.3	 集团内汇兑-单笔 (CFRT01交易)
     */
    private RetAtsSglDetail d_190802A(ReqSingle p_req1908) throws Exception {
        RetAtsSglDetail retDetail = new RetAtsSglDetail();

        try {
            //赋值通用参数
            ABC02Header bankHeader = new ABC02Header();

            bankHeader.CCTransCode = "CFRT01";
            bankHeader.ReqSeqNo = p_req1908.singleDetail.askNumber;
            bankHeader.ReqDateTime = p_req1908.singleDetail.getPayDateTime();
            XmlTextWriter xmlWriter = new XmlTextWriter();//发银行报文的XML对象
            //写入通用的头部节点
            writeCommonHeader(xmlWriter, bankHeader);
            xmlWriter.writeElementString("Amt", p_req1908.singleDetail.payAmount);
            xmlWriter.writeStartElement("Cmp");
            String dbProv = p_req1908.singleDetail.payArea;
            if (getBankConfig().getValueAsBool("payActInfoSetOwnerArea")) {
                String payact = p_req1908.singleDetail.payAct;
                if ((payact.indexOf('-') == 2 && payact.length() == 18) || (payact.length() == 17)) {
                    dbProv = payact.substring(0, 2);
                } else if (payact.indexOf('-') == 15 && payact.length() == 18) {
                    dbProv = payact.substring(16);
                }
            }
            xmlWriter.writeElementString("DbProv", dbProv);
            xmlWriter.writeElementString("DbAccNo", getAbcAccNo(p_req1908.singleDetail.payAct));
            xmlWriter.writeElementClosed("DbLogAccNo");
            xmlWriter.writeElementString("DbCur", this.convertCurToBank(p_req1908.singleDetail.payCur));
            if (p_req1908.singleDetail.sameBnk.equals("1")) {
                String crProv = p_req1908.singleDetail.recArea;
                if (getBankConfig().getValueAsBool("useActInfoSetOwnerArea")) {
                    String recact = p_req1908.singleDetail.recAct;
                    if ((recact.indexOf('-') == 2 && recact.length() == 18) || (recact.length() == 17)) {
                        crProv = recact.substring(0, 2);
                    } else if (recact.indexOf('-') == 15 && recact.length() == 18) {
                        crProv = recact.substring(16, 18);
                    }
                }
                if ("true".equals(getBankConfig().getValueAsString("setCrProvWithEmpty").toLowerCase()) && "1".equals(p_req1908.singleDetail.isPrivate)) {
                    crProv = "";
                }
                xmlWriter.writeElementString("CrProv", crProv);
                xmlWriter.writeElementString("CrAccNo", getAbcAccNo(p_req1908.singleDetail.recAct));
            } else {
                xmlWriter.writeElementClosed("CrProv");
                xmlWriter.writeElementString("CrAccNo", p_req1908.singleDetail.recAct);
            }
            xmlWriter.writeElementClosed("CrLogAccNo");
            xmlWriter.writeElementString("CrCur", this.convertCurToBank(p_req1908.singleDetail.recCur));
            xmlWriter.writeElementString("ConFlag", "1");
            xmlWriter.writeEndElement();
            //需要进行对账码拼接以及节点解析，采用XElement进行处理
            //单笔、批量共用节点赋值方法
            XElement tmpXElement = new XElement("Corp", "");
            tmpXElement.addChild(new XElement("SubAccNo", ""));
            tmpXElement.addChild(new XElement("SubAccName", ""));
            tmpXElement.addChild(new XElement("BookingDate", ""));//p_req1908.singleDetail.payDate
            tmpXElement.addChild(new XElement("BookingTime", ""));//p_req1908.singleDetail.payTime
            tmpXElement.addChild(new XElement("BookingFlag", "0"));
            tmpXElement.addChild(new XElement("Postscript", p_req1908.singleDetail.abstractATS));
            tmpXElement.addChild(new XElement("PostscriptRes", ""));
            tmpXElement.addChild(new XElement("CrAccName", p_req1908.singleDetail.recName));
            tmpXElement.addChild(new XElement("DbAccName", p_req1908.singleDetail.payName));
            tmpXElement.addChild(new XElement("WhyUse", p_req1908.singleDetail.purpose));
            String urgencyFlag = p_req1908.singleDetail.paySpd;//加急标识
            if (p_req1908.singleDetail.sameBnk.equals("1")) {
                tmpXElement.addChild(new XElement("OthBankFlag", "0"));
            } else {
                tmpXElement.addChild(new XElement("OthBankFlag", "1"));
                String urgentFlag = getBankConfig().getValueAsString("UrgentLargeAmount");
                if (StringHelper.hasAnyChar(urgentFlag)) {
                    if ((new BigDecimal(p_req1908.singleDetail.payAmount)).compareTo(new BigDecimal(urgentFlag)) >= 0) {
                        urgencyFlag = "1";
                    }
                }
            }
            nodeAnalysis(p_req1908.singleDetail.srcXElement, tmpXElement, getCharset());

            xmlWriter.writeXElement(tmpXElement);

            xmlWriter.writeEndDocument();//写入报文完成
            String[] tmpStrRet = sendToBank(xmlWriter.toXmlString());//发送银行
            if (tmpStrRet[0].length() == 0) {
                StringBuilder tmpSbMsg = new StringBuilder();
                //解析银行返回
                XmlTextReader tmpBkReader = loadBankRespXmlReader(tmpStrRet[1], tmpSbMsg);
                if (tmpBkReader != null) {
                    String tmpRespCode = tmpBkReader.getFirstText("/ap/RespCode");
                    String tmpRetInfo = tmpBkReader.getFirstText("/ap/RespInfo");
                    String tmpRetRxtInfo = tmpBkReader.getFirstText("/ap/RxtInfo");
                    String tmpRespSource = tmpBkReader.getFirstText("/ap/RespSource");

                    retDetail.respCode = "0";
                    retDetail.reqSeqID = p_req1908.singleDetail.askNumber;
                    retDetail.transState = tmpRespSource + "+" + tmpRespCode;
                    String tmpWaitFlag = tmpBkReader.getFirstText("/ap/Corp/WaitFlag");
                    if (tmpWaitFlag != null && tmpWaitFlag.length() > 0) {
                        retDetail.transState = retDetail.transState + "+" + tmpWaitFlag;
                    }
                    retDetail.payInfoCode = tmpRespCode;
                    retDetail.respInfo = StringHelper.joinNotEmpty("+", tmpRetInfo, tmpRetRxtInfo);
                } else {
                    retDetail.respCode = "-1";
                    retDetail.respInfo = tmpSbMsg.toString();
                }
            } else if (tmpStrRet[0].equals(ConnState.FAIL)) {
                retDetail.respCode = "0";
                retDetail.respInfo = tmpStrRet[1];
                retDetail.reqSeqID = p_req1908.singleDetail.askNumber;
                retDetail.transState = PaymentState.FAIL_Payment;
                retDetail.payInfoCode = tmpStrRet[0];
            } else {
                retDetail.respCode = "-1";
                retDetail.respInfo = tmpStrRet[1];
            }
        } catch (Exception ex) {
            ex.printStackTrace();

            retDetail.respCode = "-1";
            retDetail.respInfo = ex.getMessage();

            WriteBankLogLn(ex);
        }

        return retDetail;
    }

    /**
     * 内部调拨
     *
     * @param p_req1908
     * @return
     * @throws Exception
     */
    private RetAtsSglDetail d_190801(ReqSingle p_req1908) throws Exception {
        RetAtsSglDetail tmpRetDetail = new RetAtsSglDetail();
        tmpRetDetail.reqSeqID = p_req1908.singleDetail.askNumber;

        ABC02Header bankHeader = new ABC02Header();
        bankHeader.CCTransCode = ABC02TransCode.deal_1908_190801;
        bankHeader.ReqSeqNo = p_req1908.singleDetail.askNumber;
        bankHeader.ReqDateTime = p_req1908.singleDetail.getPayDateTime();

        XmlTextWriter xmlWriter = new XmlTextWriter();
        writeCommonHeader(xmlWriter, bankHeader);
        xmlWriter.writeElementString("Amt", p_req1908.singleDetail.payAmount);
        xmlWriter.writeStartElement("Cmp");

        String subAct = "";
        String subArea = "";
        String subCur = "";
        if ("0".equalsIgnoreCase(p_req1908.singleDetail.primaryAct)) {
            subAct = p_req1908.singleDetail.payAct;
            subArea = p_req1908.singleDetail.payArea;
            subCur = p_req1908.singleDetail.payCur;
        } else {
            subAct = p_req1908.singleDetail.recAct;
            subArea = p_req1908.singleDetail.recArea;
            subCur = p_req1908.singleDetail.recCur;
        }
        xmlWriter.writeElementString("DbAccNo", getAbcAccNo(subAct));
        xmlWriter.writeElementString("DbProv", subArea);
        xmlWriter.writeElementString("DbCur", this.convertCurToBank(subCur));
        xmlWriter.writeElementString("TrFlag", p_req1908.singleDetail.primaryAct);
        xmlWriter.writeEndElement();
        XElement tmpXElement = new XElement("Corp", "");
        tmpXElement.addChild(new XElement("Postscript", p_req1908.singleDetail.abstractATS));
        nodeAnalysis(p_req1908.singleDetail.srcXElement, tmpXElement, getCharset());
        xmlWriter.writeXElement(tmpXElement);
        xmlWriter.writeEndDocument();

        String[] tmpStrRet = sendToBank(xmlWriter.toXmlString());

        if (tmpStrRet[0].length() == 0) {
            StringBuilder tmpSbMsg = new StringBuilder();
            XmlTextReader tmpBkReader = loadBankRespXmlReader(tmpStrRet[1], tmpSbMsg);
            if (tmpBkReader != null) {
                String tmpRespCode = tmpBkReader.getFirstText("/ap/RespCode");
                String tmpRetInfo = tmpBkReader.getFirstText("/ap/RespInfo");
                String tmpRetRxtInfo = tmpBkReader.getFirstText("/ap/RxtInfo");
                String tmpRespSource = tmpBkReader.getFirstText("/ap/RespSource");

                tmpRetDetail.respCode = "0";
                tmpRetDetail.respInfo = StringHelper.joinNotEmpty("+", tmpRetInfo, tmpRetRxtInfo);

                tmpRetDetail.transState = tmpRespSource + "+" + tmpRespCode;
                tmpRetDetail.payInfoCode = tmpRespCode;
            } else {
                tmpRetDetail.respCode = "-1";
                tmpRetDetail.respInfo = tmpSbMsg.toString();
            }
        } else if (tmpStrRet[0].equals(ConnState.FAIL)) {
            tmpRetDetail.respCode = "0";
            tmpRetDetail.respInfo = tmpStrRet[1];
            tmpRetDetail.reqSeqID = p_req1908.singleDetail.askNumber;
            tmpRetDetail.transState = PaymentState.FAIL_Payment;
            tmpRetDetail.payInfoCode = tmpStrRet[0];
        } else {
            tmpRetDetail.respCode = "-1";
            tmpRetDetail.respInfo = tmpStrRet[1];
        }

        return tmpRetDetail;
    }

    //1944 状态查询
    @Override
    public RetAtsSingle d_1944_QrySglPay(ReqQrySingle p_req1944) throws Exception {
        RetAtsSingle retAts = new RetAtsSingle(p_req1944.reqHeader);
        RetAtsSglDetail tmpRetDetail = new RetAtsSglDetail(p_req1944);

        try {
            if (StringHelper.isNullOrEmpty(p_req1944.payArea)) {
                tmpRetDetail.respCode = "-1";
                tmpRetDetail.respInfo = "PayArea不能为空";
            } else if (StringHelper.isNullOrEmpty(p_req1944.payAct)) {
                tmpRetDetail.respCode = "-1";
                tmpRetDetail.respInfo = "PayAct不能为空";
            }
            if (StringHelper.isNullOrEmpty(tmpRetDetail.respCode)) {
                XmlTextWriter xmlWriter = new XmlTextWriter();//发银行报文的XML对象
                ABC02Header bankHeader = new ABC02Header();
                if (getBankConfig().getValueAsBool("useNewQrySglPay")) {
                    bankHeader.CCTransCode = "CQRT71";
                    bankHeader.ReqSeqNo = p_req1944.reqHeader.transSeqID;
                    writeCommonHeader(xmlWriter, bankHeader);//写入通用的头部节点
                    xmlWriter.writeStartElement("Cme");
                    xmlWriter.writeElementString("SerialNo", p_req1944.askNumber);
                } else {
                    bankHeader.CCTransCode = "CQRT04";
                    bankHeader.ReqSeqNo = p_req1944.reqHeader.transSeqID;
                    writeCommonHeader(xmlWriter, bankHeader);//写入通用的头部节点
                    xmlWriter.writeStartElement("Cmp");
                    xmlWriter.writeElementString("DbProv", p_req1944.payArea);
                    xmlWriter.writeElementString("DbAccNo", this.getAbcAccNo(p_req1944.payAct));
                    String tmpCur = p_req1944.payCur;
                    if (StringHelper.isNullOrEmpty(tmpCur)) {
                        tmpCur = "1";
                    }
                    xmlWriter.writeElementString("DbCur", this.convertCurToBank(tmpCur));
                    xmlWriter.writeElementString("CmeSeqNo", p_req1944.askNumber);
                }
                xmlWriter.writeEndDocument();

                String[] tmpStrRet = sendToBank(xmlWriter.toXmlString());

                if (tmpStrRet[0].length() == 0) {
                    StringBuilder tmpSbMsg = new StringBuilder();
                    XmlTextReader tmpBkReader = loadBankRespXmlReader(tmpStrRet[1], tmpSbMsg);
                    if (tmpBkReader != null) {
                        String tmpRespCode = tmpBkReader.getFirstText("/ap/RespCode");
                        String tmpRetInfo = tmpBkReader.getFirstText("/ap/RespInfo");
                        String tmpRetRxtInfo = tmpBkReader.getFirstText("/ap/RxtInfo");
                        if (tmpRespCode.equals("0000")) {
                            tmpRetDetail.respCode = "0";
                            tmpRetDetail.respInfo = tmpRetInfo + "+" + tmpRetRxtInfo;
                            if (getBankConfig().getValueAsBool("useNewQrySglPay")) {
                                String tmpRespPrvData = tmpBkReader.getFirstText("/ap/Cmp/RespPrvData");
                                if (StringHelper.hasAnyChar(tmpRespPrvData)) {
                                    tmpRetDetail.respInfo = tmpRespPrvData;
                                }
                                tmpRetDetail.transState = tmpRespCode + "+" + tmpBkReader.getFirstText("/ap/Cmp/TransSta");
                                tmpRetDetail.payInfoCode = tmpRetDetail.transState;
                            } else {
                                String tmpCmeSeqNo = tmpBkReader.getFirstText("/ap/Cmp/CmeSeqNo");
                                String tmpRespPrvData = tmpBkReader.getFirstText("/ap/Cmp/RespPrvData");
                                String tmpTransState = tmpRespPrvData.replace("1970 1", "");
                                tmpTransState = tmpTransState.replace(tmpCmeSeqNo, "");
                                tmpTransState = tmpTransState.trim();
                                tmpRetDetail.transState = tmpTransState;
                                String tmpRespInfo = tmpBkReader.getFirstText("/ap/Corp/Postscript").trim().replaceAll(" ", "");
                                tmpRetDetail.respInfo = tmpRespInfo;
                                if ("EDP9EDP9".equals(tmpTransState)) {
                                    tmpRetDetail.payInfoCode = tmpRespInfo;
                                } else {
                                    tmpRetDetail.payInfoCode = tmpTransState;
                                }
                            }
                        } else {
                            tmpRetDetail.respCode = "-1";
                            if (!StringHelper.isNullOrEmpty(tmpRetRxtInfo)) {
                                tmpRetDetail.respInfo = tmpRetRxtInfo;
                            } else {
                                tmpRetDetail.respInfo = tmpRetInfo;
                            }
                        }
                    } else {
                        tmpRetDetail.respCode = "-1";
                        tmpRetDetail.respInfo = tmpSbMsg.toString();
                    }
                } else {
                    tmpRetDetail.respCode = "-1";
                    tmpRetDetail.respInfo = tmpStrRet[1];
                }
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            tmpRetDetail.respCode = "-1";
            tmpRetDetail.respInfo = ex.getMessage();
            WriteBankLogLn(ex);
        }

        retAts.writeRetDetail(tmpRetDetail);
        return retAts;
    }

    @Override
    public RetAtsSingleBat d_1944BAT_QrySglBatPay(ReqQrySingleBat p_req1944BAT) throws Exception {
        return null;
    }
}
